/****** SQL DB AND TABLES******/

USE [master]
GO
/****** Object:  Database [SimulationDevDB]    Script Date: 04/29/2011 13:11:32 ******/
CREATE DATABASE [SimulationDevDB] ON  PRIMARY 
( NAME = N'SimulationDevDB', FILENAME = N'c:\Program Files\Microsoft SQL Server\MSSQL.1\MSSQL\DATA\SimulationDevDB.mdf' , SIZE = 8192KB , MAXSIZE = UNLIMITED, FILEGROWTH = 1024KB )
 LOG ON 
( NAME = N'SimulationDevDB_log', FILENAME = N'c:\Program Files\Microsoft SQL Server\MSSQL.1\MSSQL\DATA\SimulationDevDB_log.ldf' , SIZE = 2304KB , MAXSIZE = 2048GB , FILEGROWTH = 10%)
 COLLATE SQL_Latin1_General_CP1_CI_AS
GO
EXEC dbo.sp_dbcmptlevel @dbname=N'SimulationDevDB', @new_cmptlevel=90
GO
IF (1 = FULLTEXTSERVICEPROPERTY('IsFullTextInstalled'))
begin
EXEC [SimulationDevDB].[dbo].[sp_fulltext_database] @action = 'enable'
end
GO
ALTER DATABASE [SimulationDevDB] SET ANSI_NULL_DEFAULT OFF 
GO
ALTER DATABASE [SimulationDevDB] SET ANSI_NULLS OFF 
GO
ALTER DATABASE [SimulationDevDB] SET ANSI_PADDING OFF 
GO
ALTER DATABASE [SimulationDevDB] SET ANSI_WARNINGS OFF 
GO
ALTER DATABASE [SimulationDevDB] SET ARITHABORT OFF 
GO
ALTER DATABASE [SimulationDevDB] SET AUTO_CLOSE OFF 
GO
ALTER DATABASE [SimulationDevDB] SET AUTO_CREATE_STATISTICS ON 
GO
ALTER DATABASE [SimulationDevDB] SET AUTO_SHRINK OFF 
GO
ALTER DATABASE [SimulationDevDB] SET AUTO_UPDATE_STATISTICS ON 
GO
ALTER DATABASE [SimulationDevDB] SET CURSOR_CLOSE_ON_COMMIT OFF 
GO
ALTER DATABASE [SimulationDevDB] SET CURSOR_DEFAULT  GLOBAL 
GO
ALTER DATABASE [SimulationDevDB] SET CONCAT_NULL_YIELDS_NULL OFF 
GO
ALTER DATABASE [SimulationDevDB] SET NUMERIC_ROUNDABORT OFF 
GO
ALTER DATABASE [SimulationDevDB] SET QUOTED_IDENTIFIER OFF 
GO
ALTER DATABASE [SimulationDevDB] SET RECURSIVE_TRIGGERS OFF 
GO
ALTER DATABASE [SimulationDevDB] SET  ENABLE_BROKER 
GO
ALTER DATABASE [SimulationDevDB] SET AUTO_UPDATE_STATISTICS_ASYNC OFF 
GO
ALTER DATABASE [SimulationDevDB] SET DATE_CORRELATION_OPTIMIZATION OFF 
GO
ALTER DATABASE [SimulationDevDB] SET TRUSTWORTHY OFF 
GO
ALTER DATABASE [SimulationDevDB] SET ALLOW_SNAPSHOT_ISOLATION OFF 
GO
ALTER DATABASE [SimulationDevDB] SET PARAMETERIZATION SIMPLE 
GO
ALTER DATABASE [SimulationDevDB] SET  READ_WRITE 
GO
ALTER DATABASE [SimulationDevDB] SET RECOVERY SIMPLE 
GO
ALTER DATABASE [SimulationDevDB] SET  MULTI_USER 
GO
ALTER DATABASE [SimulationDevDB] SET PAGE_VERIFY CHECKSUM  
GO
ALTER DATABASE [SimulationDevDB] SET DB_CHAINING OFF 


USE [SimulationDevDB]
GO
/****** Object:  Table [dbo].[USER_TABLE]    Script Date: 04/29/2011 13:02:57 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
SET ANSI_PADDING ON
GO
CREATE TABLE [dbo].[USER_TABLE](
	[U_ID] [int] IDENTITY(1,1) NOT NULL,
	[U_NAME] [varchar](50) COLLATE SQL_Latin1_General_CP1_CI_AS NOT NULL,
	[U_PASSWORD] [varchar](50) COLLATE SQL_Latin1_General_CP1_CI_AS NOT NULL,
	[U_EMAIL] [varchar](50) COLLATE SQL_Latin1_General_CP1_CI_AS NOT NULL,
	[U_SETUP] [varchar](max) COLLATE SQL_Latin1_General_CP1_CI_AS NOT NULL,
 CONSTRAINT [PK_USER_TABLE] PRIMARY KEY CLUSTERED 
(
	[U_ID] ASC
)WITH (PAD_INDEX  = OFF, IGNORE_DUP_KEY = OFF) ON [PRIMARY]
) ON [PRIMARY]

GO
SET ANSI_PADDING OFF



USE [SimulationDevDB]
GO
/****** Object:  Table [dbo].[SIMULATION_TABLE]    Script Date: 04/29/2011 13:02:30 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
SET ANSI_PADDING ON
GO
CREATE TABLE [dbo].[SIMULATION_TABLE](
	[S_ID] [int] IDENTITY(1,1) NOT NULL,
	[S_NAME] [varchar](50) COLLATE SQL_Latin1_General_CP1_CI_AS NOT NULL,
	[S_DESC] [varchar](50) COLLATE SQL_Latin1_General_CP1_CI_AS NOT NULL,
	[S_STATUS] [int] NOT NULL,
	[S_SETUP] [varchar](max) COLLATE SQL_Latin1_General_CP1_CI_AS NOT NULL,
	[U_ID] [int] NOT NULL,
 CONSTRAINT [PK_SIMULATION_TABLE] PRIMARY KEY CLUSTERED 
(
	[S_ID] ASC
)WITH (PAD_INDEX  = OFF, IGNORE_DUP_KEY = OFF) ON [PRIMARY]
) ON [PRIMARY]

GO
SET ANSI_PADDING OFF
GO
ALTER TABLE [dbo].[SIMULATION_TABLE]  WITH CHECK ADD  CONSTRAINT [FK_SIMULATION_TABLE_USER_TABLE] FOREIGN KEY([U_ID])
REFERENCES [dbo].[USER_TABLE] ([U_ID])
ON UPDATE CASCADE
ON DELETE CASCADE
GO
ALTER TABLE [dbo].[SIMULATION_TABLE] CHECK CONSTRAINT [FK_SIMULATION_TABLE_USER_TABLE]



USE [SimulationDevDB]
GO
/****** Object:  Table [dbo].[TRAINING_TABLE]    Script Date: 04/29/2011 13:02:46 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
SET ANSI_PADDING ON
GO
CREATE TABLE [dbo].[TRAINING_TABLE](
	[T_ID] [int] IDENTITY(1,1) NOT NULL,
	[T_NAME] [varchar](50) COLLATE SQL_Latin1_General_CP1_CI_AS NOT NULL,
	[T_DESC] [varchar](50) COLLATE SQL_Latin1_General_CP1_CI_AS NOT NULL,
	[T_SETUP] [varchar](max) COLLATE SQL_Latin1_General_CP1_CI_AS NOT NULL,
	[U_ID] [int] NOT NULL,
 CONSTRAINT [PK_TRAINING_TABLE] PRIMARY KEY CLUSTERED 
(
	[T_ID] ASC
)WITH (PAD_INDEX  = OFF, IGNORE_DUP_KEY = OFF) ON [PRIMARY]
) ON [PRIMARY]

GO
SET ANSI_PADDING OFF
GO
ALTER TABLE [dbo].[TRAINING_TABLE]  WITH CHECK ADD  CONSTRAINT [FK_TRAINING_TABLE_USER_TABLE] FOREIGN KEY([U_ID])
REFERENCES [dbo].[USER_TABLE] ([U_ID])
ON UPDATE CASCADE
ON DELETE CASCADE
GO
ALTER TABLE [dbo].[TRAINING_TABLE] CHECK CONSTRAINT [FK_TRAINING_TABLE_USER_TABLE]



USE [SimulationDevDB]
GO
/****** Object:  Table [dbo].[REPORT_TABLE]    Script Date: 04/29/2011 13:02:18 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
SET ANSI_PADDING ON
GO
CREATE TABLE [dbo].[REPORT_TABLE](
	[R_ID] [int] IDENTITY(1,1) NOT NULL,
	[S_ID] [int] NOT NULL,
	[R_STATUS] [varchar](50) COLLATE SQL_Latin1_General_CP1_CI_AS NOT NULL,
	[R_DATA] [varbinary](max) NULL,
	[R_TIMESTAMP] [datetime] NULL,
 CONSTRAINT [PK_REPORT_TABLE] PRIMARY KEY CLUSTERED 
(
	[R_ID] ASC
)WITH (PAD_INDEX  = OFF, IGNORE_DUP_KEY = OFF) ON [PRIMARY]
) ON [PRIMARY]

GO
SET ANSI_PADDING OFF
GO
ALTER TABLE [dbo].[REPORT_TABLE]  WITH CHECK ADD  CONSTRAINT [FK_REPORT_TABLE_SIMULATION_TABLE] FOREIGN KEY([S_ID])
REFERENCES [dbo].[SIMULATION_TABLE] ([S_ID])
ON UPDATE CASCADE
ON DELETE CASCADE
GO
ALTER TABLE [dbo].[REPORT_TABLE] CHECK CONSTRAINT [FK_REPORT_TABLE_SIMULATION_TABLE]




USE [SimulationDevDB]
GO
/****** Object:  Table [dbo].[PLAYER_TABLE]    Script Date: 04/29/2011 13:01:58 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
SET ANSI_PADDING ON
GO
CREATE TABLE [dbo].[PLAYER_TABLE](
	[P_ID] [int] IDENTITY(1,1) NOT NULL,
	[P_NAME] [varchar](50) COLLATE SQL_Latin1_General_CP1_CI_AS NOT NULL,
	[P_DESC] [varchar](50) COLLATE SQL_Latin1_General_CP1_CI_AS NOT NULL,
	[P_SETUP] [varchar](max) COLLATE SQL_Latin1_General_CP1_CI_AS NOT NULL,
	[U_ID] [int] NOT NULL,
 CONSTRAINT [PK_PLAYER_TABLE] PRIMARY KEY CLUSTERED 
(
	[P_ID] ASC
)WITH (PAD_INDEX  = OFF, IGNORE_DUP_KEY = OFF) ON [PRIMARY]
) ON [PRIMARY]

GO
SET ANSI_PADDING OFF
GO
ALTER TABLE [dbo].[PLAYER_TABLE]  WITH CHECK ADD  CONSTRAINT [FK_PLAYER_TABLE_USER_TABLE] FOREIGN KEY([U_ID])
REFERENCES [dbo].[USER_TABLE] ([U_ID])
ON UPDATE CASCADE
ON DELETE CASCADE
GO
ALTER TABLE [dbo].[PLAYER_TABLE] CHECK CONSTRAINT [FK_PLAYER_TABLE_USER_TABLE]


USE [SimulationDevDB]
GO
/****** Object:  Table [dbo].[INJURY_TABLE]    Script Date: 04/29/2011 13:01:36 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
SET ANSI_PADDING ON
GO
CREATE TABLE [dbo].[INJURY_TABLE](
	[I_ID] [int] IDENTITY(1,1) NOT NULL,
	[I_NAME] [varchar](50) COLLATE SQL_Latin1_General_CP1_CI_AS NOT NULL,
	[I_DESC] [varchar](50) COLLATE SQL_Latin1_General_CP1_CI_AS NOT NULL,
	[I_SETUP] [varchar](max) COLLATE SQL_Latin1_General_CP1_CI_AS NOT NULL,
	[U_ID] [int] NOT NULL,
 CONSTRAINT [PK_INJURY_TABLE] PRIMARY KEY CLUSTERED 
(
	[I_ID] ASC
)WITH (PAD_INDEX  = OFF, IGNORE_DUP_KEY = OFF) ON [PRIMARY]
) ON [PRIMARY]

GO
SET ANSI_PADDING OFF
GO
ALTER TABLE [dbo].[INJURY_TABLE]  WITH CHECK ADD  CONSTRAINT [FK_INJURY_TABLE_USER_TABLE] FOREIGN KEY([U_ID])
REFERENCES [dbo].[USER_TABLE] ([U_ID])
ON UPDATE CASCADE
ON DELETE CASCADE
GO
ALTER TABLE [dbo].[INJURY_TABLE] CHECK CONSTRAINT [FK_INJURY_TABLE_USER_TABLE]


/****** SQL STORED PROCEDURES ******/

GO
CREATE PROCEDURE [dbo].[DELETE_INJURY]
	-- Add the parameters for the stored procedure here
	@ID int
AS
BEGIN
	-- SET NOCOUNT ON added to prevent extra result sets from
	-- interfering with SELECT statements.
	SET NOCOUNT ON;

    -- Insert statements for procedure here
	DELETE INJURY_TABLE WHERE I_ID=@ID
END


GO
-- =============================================
-- Author:		<Author,,Name>
-- Create date: <Create Date,,>
-- Description:	<Description,,>
-- =============================================
CREATE PROCEDURE [dbo].[DELETE_PLAYER]
	-- Add the parameters for the stored procedure here
	@ID int
AS
BEGIN
	-- SET NOCOUNT ON added to prevent extra result sets from
	-- interfering with SELECT statements.
	SET NOCOUNT ON;

    -- Insert statements for procedure here
	DELETE PLAYER_TABLE WHERE P_ID=@ID
END




GO
-- =============================================
-- Author:		<Author,,Name>
-- Create date: <Create Date,,>
-- Description:	<Description,,>
-- =============================================
CREATE PROCEDURE [dbo].[DELETE_SIMULATION]
	-- Add the parameters for the stored procedure here
	@ID int
AS
BEGIN
	-- SET NOCOUNT ON added to prevent extra result sets from
	-- interfering with SELECT statements.
	SET NOCOUNT ON;

    -- Insert statements for procedure here
	DELETE SIMULATION_TABLE WHERE S_ID=@ID
END



GO
-- =============================================
-- Author:		<Author,,Name>
-- Create date: <Create Date,,>
-- Description:	<Description,,>
-- =============================================
CREATE PROCEDURE [dbo].[DELETE_TRAINING]
	-- Add the parameters for the stored procedure here
	@ID int
AS
BEGIN
	-- SET NOCOUNT ON added to prevent extra result sets from
	-- interfering with SELECT statements.
	SET NOCOUNT ON;

    -- Insert statements for procedure here
	DELETE TRAINING_TABLE WHERE T_ID=@ID
END


GO
-- =============================================
-- Author:		<Author,,Name>
-- Create date: <Create Date,,>
-- Description:	<Description,,>
-- =============================================
CREATE PROCEDURE [dbo].[FET_ALL_PLAYERS]
	-- Add the parameters for the stored procedure here
AS
BEGIN
	-- SET NOCOUNT ON added to prevent extra result sets from
	-- interfering with SELECT statements.
	SET NOCOUNT ON;

    
	SELECT * FROM PLAYER_TABLE
END




GO
-- =============================================
-- Author:		<Author,,Name>
-- Create date: <Create Date,,>
-- Description:	<Description,,>
-- =============================================
CREATE PROCEDURE [dbo].[FET_INJURIES]
	-- Add the parameters for the stored procedure here
	@ID int
AS
BEGIN
	-- SET NOCOUNT ON added to prevent extra result sets from
	-- interfering with SELECT statements.
	SET NOCOUNT ON;

    
	SELECT * FROM INJURY_TABLE WHERE U_ID=@ID
END


GO
-- =============================================
-- Author:		<Author,,Name>
-- Create date: <Create Date,,>
-- Description:	<Description,,>
-- =============================================
CREATE PROCEDURE [dbo].[FET_INJURY]
	-- Add the parameters for the stored procedure here
	@ID int
AS
BEGIN
	-- SET NOCOUNT ON added to prevent extra result sets from
	-- interfering with SELECT statements.
	SET NOCOUNT ON;

    
	SELECT * FROM INJURY_TABLE WHERE I_ID=@ID
END




GO
-- =============================================
-- Author:		<Author,,Name>
-- Create date: <Create Date,,>
-- Description:	<Description,,>
-- =============================================
CREATE PROCEDURE [dbo].[FET_PLAYER]
	-- Add the parameters for the stored procedure here
	@ID int
AS
BEGIN
	-- SET NOCOUNT ON added to prevent extra result sets from
	-- interfering with SELECT statements.
	SET NOCOUNT ON;

    
	SELECT * FROM PLAYER_TABLE WHERE P_ID=@ID
END




GO
-- =============================================
-- Author:		<Author,,Name>
-- Create date: <Create Date,,>
-- Description:	<Description,,>
-- =============================================
CREATE PROCEDURE [dbo].[FET_PLAYERS]
	-- Add the parameters for the stored procedure here
	@ID int
AS
BEGIN
	-- SET NOCOUNT ON added to prevent extra result sets from
	-- interfering with SELECT statements.
	SET NOCOUNT ON;

    
	SELECT * FROM PLAYER_TABLE WHERE U_ID=@ID
END


GO
-- =============================================
-- Author:		<Author,,Name>
-- Create date: <Create Date,,>
-- Description:	<Description,,>
-- =============================================
CREATE PROCEDURE [dbo].[FET_SIMULATION]
	-- Add the parameters for the stored procedure here
	@ID int
AS
BEGIN
	-- SET NOCOUNT ON added to prevent extra result sets from
	-- interfering with SELECT statements.
	SET NOCOUNT ON;

    
	SELECT * FROM SIMULATION_TABLE WHERE S_ID=@ID
END


GO
-- =============================================
-- Author:		<Author,,Name>
-- Create date: <Create Date,,>
-- Description:	<Description,,>
-- =============================================
CREATE PROCEDURE [dbo].[FET_SIMULATIONS]
	-- Add the parameters for the stored procedure here
	@ID int
AS
BEGIN
	-- SET NOCOUNT ON added to prevent extra result sets from
	-- interfering with SELECT statements.
	SET NOCOUNT ON;

    
	SELECT * FROM SIMULATION_TABLE WHERE U_ID=@ID
END



GO
-- =============================================
-- Author:		<Author,,Name>
-- Create date: <Create Date,,>
-- Description:	<Description,,>
-- =============================================
CREATE PROCEDURE [dbo].[FET_TRAINING]
	-- Add the parameters for the stored procedure here
	@ID int
AS
BEGIN
	-- SET NOCOUNT ON added to prevent extra result sets from
	-- interfering with SELECT statements.
	SET NOCOUNT ON;

    
	SELECT * FROM TRAINING_TABLE WHERE T_ID=@ID
END


GO
-- =============================================
-- Author:		<Author,,Name>
-- Create date: <Create Date,,>
-- Description:	<Description,,>
-- =============================================
CREATE PROCEDURE [dbo].[FET_TRAININGS]
	-- Add the parameters for the stored procedure here
	@ID int
AS
BEGIN
	-- SET NOCOUNT ON added to prevent extra result sets from
	-- interfering with SELECT statements.
	SET NOCOUNT ON;

    
	SELECT * FROM TRAINING_TABLE WHERE U_ID=@ID
END



GO
-- =============================================
-- Author:		<Author,,Name>
-- Create date: <Create Date,,>
-- Description:	<Description,,>
-- =============================================
CREATE PROCEDURE [dbo].[INS_NEW_DEFAULT_INJURY]
	@Name varchar(50),
	@Desc varchar(50),
	@Setup varchar(max),
	@Id int
AS
BEGIN
	-- SET NOCOUNT ON added to prevent extra result sets from
	-- interfering with SELECT statements.
	SET NOCOUNT ON;

   INSERT INTO INJURY_TABLE
	VALUES(@Name, @Desc, @Setup,@Id)

END



GO
-- =============================================
-- Author:		<Author,,Name>
-- Create date: <Create Date,,>
-- Description:	<Description,,>
-- =============================================
CREATE PROCEDURE [dbo].[INS_NEW_DEFAULT_PLAYER]
	@Name varchar(50),
	@Desc varchar(50),
	@Setup varchar(max),
	@Id int
AS
BEGIN
	-- SET NOCOUNT ON added to prevent extra result sets from
	-- interfering with SELECT statements.
	SET NOCOUNT ON;

   INSERT INTO PLAYER_TABLE
	VALUES(@Name, @Desc, @Setup,@Id)

END




GO
-- =============================================
-- Author:		<Author,,Name>
-- Create date: <Create Date,,>
-- Description:	<Description,,>
-- =============================================
CREATE PROCEDURE [dbo].[INS_NEW_REPORT_ENTRY]
	@sId int


AS
BEGIN
	-- SET NOCOUNT ON added to prevent extra result sets from
	-- interfering with SELECT statements.
	SET NOCOUNT ON;

   INSERT INTO REPORT_TABLE(S_ID,R_STATUS)
	VALUES(@sId, 'RUNNING')

	SELECT SCOPE_IDENTITY() AS [SCOPE_IDENTITY]


END



GO
-- =============================================
-- Author:		<Author,,Name>
-- Create date: <Create Date,,>
-- Description:	<Description,,>
-- =============================================
CREATE PROCEDURE [dbo].[INS_NEW_DEFAULT_SIMULATION]
	@Name varchar(50),
	@Desc varchar(50),
	@Status int,
	@Setup varchar(max),
	@Id int
AS
BEGIN
	-- SET NOCOUNT ON added to prevent extra result sets from
	-- interfering with SELECT statements.
	SET NOCOUNT ON;

   INSERT INTO SIMULATION_TABLE
	VALUES(@Name, @Desc, @Status,@Setup,@Id)

END



GO
-- =============================================
-- Author:		<Author,,Name>
-- Create date: <Create Date,,>
-- Description:	<Description,,>
-- =============================================
CREATE PROCEDURE [dbo].[INS_NEW_DEFAULT_TRAINING]
	@Name varchar(50),
	@Desc varchar(50),
	@Setup varchar(max),
	@Id int
AS
BEGIN
	-- SET NOCOUNT ON added to prevent extra result sets from
	-- interfering with SELECT statements.
	SET NOCOUNT ON;

    -- Insert statements for procedure here
	INSERT INTO TRAINING_TABLE
	VALUES(@Name, @Desc,@Setup,@Id)
END




GO
-- =============================================
-- Author:		<Author,,Name>
-- Create date: <Create Date,,>
-- Description:	<Description,,>
-- =============================================
CREATE PROCEDURE [dbo].[UPD_INJURY]
	-- Add the parameters for the stored procedure here
	@Id int,
	@Name varchar(50),
	@Desc varchar(50),
	@Setup varchar(max)
AS
BEGIN
	-- SET NOCOUNT ON added to prevent extra result sets from
	-- interfering with SELECT statements.
	SET NOCOUNT ON;

   UPDATE INJURY_TABLE
	SET
		I_NAME = @Name,
		I_DESC = @Desc,
		I_SETUP= @Setup
	WHERE
		I_ID=@Id
END



GO
-- =============================================
-- Author:		<Author,,Name>
-- Create date: <Create Date,,>
-- Description:	<Description,,>
-- =============================================
CREATE PROCEDURE [dbo].[UPD_PLAYER]
	-- Add the parameters for the stored procedure here
	@Id int,
	@Name varchar(50),
	@Desc varchar(50),
	@Setup varchar(max)
AS
BEGIN
	-- SET NOCOUNT ON added to prevent extra result sets from
	-- interfering with SELECT statements.
	SET NOCOUNT ON;

   UPDATE PLAYER_TABLE
	SET
		P_NAME = @Name,
		P_DESC = @Desc,
		P_SETUP= @Setup
	WHERE
		P_ID=@Id
END




GO
-- =============================================
-- Author:		<Author,,Name>
-- Create date: <Create Date,,>
-- Description:	<Description,,>
-- =============================================
CREATE PROCEDURE [dbo].[UPD_REPORT_ENTRY_FAILED]
	@rId int

AS
BEGIN
	-- SET NOCOUNT ON added to prevent extra result sets from
	-- interfering with SELECT statements.
	SET NOCOUNT ON;

    UPDATE REPORT_TABLE
	SET
		R_STATUS='FAILED',
		R_TIMESTAMP = CURRENT_TIMESTAMP
	WHERE
		R_ID=@rId


END


GO
-- =============================================
-- Author:		<Author,,Name>
-- Create date: <Create Date,,>
-- Description:	<Description,,>
-- =============================================
CREATE PROCEDURE [dbo].[UPD_REPORT_ENTRY_SUCCESS]

	@rId int,
	@sData varbinary(MAX)

AS
BEGIN
	-- SET NOCOUNT ON added to prevent extra result sets from
	-- interfering with SELECT statements.
	SET NOCOUNT ON;

    UPDATE REPORT_TABLE
	SET
		R_STATUS='SUCCESS',
		R_DATA = @sData,
		R_TIMESTAMP = CURRENT_TIMESTAMP
	WHERE
		R_ID=@rId


END




GO
-- =============================================
-- Author:		<Author,,Name>
-- Create date: <Create Date,,>
-- Description:	<Description,,>
-- =============================================
CREATE PROCEDURE [dbo].[UPD_SIMULATION]
	-- Add the parameters for the stored procedure here
	@Id int,
	@Name varchar(50),
	@Desc varchar(50),
	@Setup varchar(max)
AS
BEGIN
	-- SET NOCOUNT ON added to prevent extra result sets from
	-- interfering with SELECT statements.
	SET NOCOUNT ON;

   UPDATE SIMULATION_TABLE
	SET
		S_NAME = @Name,
		S_DESC = @Desc,
		S_SETUP= @Setup
	WHERE
		S_ID=@Id
END



GO
-- =============================================
-- Author:		<Author,,Name>
-- Create date: <Create Date,,>
-- Description:	<Description,,>
-- =============================================
CREATE PROCEDURE [dbo].[UPD_TRAINING]
	-- Add the parameters for the stored procedure here
	@Id int,
	@Name varchar(50),
	@Desc varchar(50),
	@Setup varchar(max)
AS
BEGIN
	-- SET NOCOUNT ON added to prevent extra result sets from
	-- interfering with SELECT statements.
	SET NOCOUNT ON;

   UPDATE TRAINING_TABLE
	SET
		T_NAME = @Name,
		T_DESC = @Desc,
		T_SETUP= @Setup
	WHERE
		T_ID=@Id
END

/****** SQL DB AND TABLES******/

USE [master]
GO
/****** Object:  Database [SimulationDevDB]    Script Date: 04/29/2011 13:11:32 ******/
CREATE DATABASE [SimulationDevDB] ON  PRIMARY 
( NAME = N'SimulationDevDB', FILENAME = N'c:\Program Files\Microsoft SQL Server\MSSQL.1\MSSQL\DATA\SimulationDevDB.mdf' , SIZE = 8192KB , MAXSIZE = UNLIMITED, FILEGROWTH = 1024KB )
 LOG ON 
( NAME = N'SimulationDevDB_log', FILENAME = N'c:\Program Files\Microsoft SQL Server\MSSQL.1\MSSQL\DATA\SimulationDevDB_log.ldf' , SIZE = 2304KB , MAXSIZE = 2048GB , FILEGROWTH = 10%)
 COLLATE SQL_Latin1_General_CP1_CI_AS
GO
EXEC dbo.sp_dbcmptlevel @dbname=N'SimulationDevDB', @new_cmptlevel=90
GO
IF (1 = FULLTEXTSERVICEPROPERTY('IsFullTextInstalled'))
begin
EXEC [SimulationDevDB].[dbo].[sp_fulltext_database] @action = 'enable'
end
GO
ALTER DATABASE [SimulationDevDB] SET ANSI_NULL_DEFAULT OFF 
GO
ALTER DATABASE [SimulationDevDB] SET ANSI_NULLS OFF 
GO
ALTER DATABASE [SimulationDevDB] SET ANSI_PADDING OFF 
GO
ALTER DATABASE [SimulationDevDB] SET ANSI_WARNINGS OFF 
GO
ALTER DATABASE [SimulationDevDB] SET ARITHABORT OFF 
GO
ALTER DATABASE [SimulationDevDB] SET AUTO_CLOSE OFF 
GO
ALTER DATABASE [SimulationDevDB] SET AUTO_CREATE_STATISTICS ON 
GO
ALTER DATABASE [SimulationDevDB] SET AUTO_SHRINK OFF 
GO
ALTER DATABASE [SimulationDevDB] SET AUTO_UPDATE_STATISTICS ON 
GO
ALTER DATABASE [SimulationDevDB] SET CURSOR_CLOSE_ON_COMMIT OFF 
GO
ALTER DATABASE [SimulationDevDB] SET CURSOR_DEFAULT  GLOBAL 
GO
ALTER DATABASE [SimulationDevDB] SET CONCAT_NULL_YIELDS_NULL OFF 
GO
ALTER DATABASE [SimulationDevDB] SET NUMERIC_ROUNDABORT OFF 
GO
ALTER DATABASE [SimulationDevDB] SET QUOTED_IDENTIFIER OFF 
GO
ALTER DATABASE [SimulationDevDB] SET RECURSIVE_TRIGGERS OFF 
GO
ALTER DATABASE [SimulationDevDB] SET  ENABLE_BROKER 
GO
ALTER DATABASE [SimulationDevDB] SET AUTO_UPDATE_STATISTICS_ASYNC OFF 
GO
ALTER DATABASE [SimulationDevDB] SET DATE_CORRELATION_OPTIMIZATION OFF 
GO
ALTER DATABASE [SimulationDevDB] SET TRUSTWORTHY OFF 
GO
ALTER DATABASE [SimulationDevDB] SET ALLOW_SNAPSHOT_ISOLATION OFF 
GO
ALTER DATABASE [SimulationDevDB] SET PARAMETERIZATION SIMPLE 
GO
ALTER DATABASE [SimulationDevDB] SET  READ_WRITE 
GO
ALTER DATABASE [SimulationDevDB] SET RECOVERY SIMPLE 
GO
ALTER DATABASE [SimulationDevDB] SET  MULTI_USER 
GO
ALTER DATABASE [SimulationDevDB] SET PAGE_VERIFY CHECKSUM  
GO
ALTER DATABASE [SimulationDevDB] SET DB_CHAINING OFF 


USE [SimulationDevDB]
GO
/****** Object:  Table [dbo].[USER_TABLE]    Script Date: 04/29/2011 13:02:57 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
SET ANSI_PADDING ON
GO
CREATE TABLE [dbo].[USER_TABLE](
	[U_ID] [int] IDENTITY(1,1) NOT NULL,
	[U_NAME] [varchar](50) COLLATE SQL_Latin1_General_CP1_CI_AS NOT NULL,
	[U_PASSWORD] [varchar](50) COLLATE SQL_Latin1_General_CP1_CI_AS NOT NULL,
	[U_EMAIL] [varchar](50) COLLATE SQL_Latin1_General_CP1_CI_AS NOT NULL,
	[U_SETUP] [varchar](max) COLLATE SQL_Latin1_General_CP1_CI_AS NOT NULL,
 CONSTRAINT [PK_USER_TABLE] PRIMARY KEY CLUSTERED 
(
	[U_ID] ASC
)WITH (PAD_INDEX  = OFF, IGNORE_DUP_KEY = OFF) ON [PRIMARY]
) ON [PRIMARY]

GO
SET ANSI_PADDING OFF



USE [SimulationDevDB]
GO
/****** Object:  Table [dbo].[SIMULATION_TABLE]    Script Date: 04/29/2011 13:02:30 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
SET ANSI_PADDING ON
GO
CREATE TABLE [dbo].[SIMULATION_TABLE](
	[S_ID] [int] IDENTITY(1,1) NOT NULL,
	[S_NAME] [varchar](50) COLLATE SQL_Latin1_General_CP1_CI_AS NOT NULL,
	[S_DESC] [varchar](50) COLLATE SQL_Latin1_General_CP1_CI_AS NOT NULL,
	[S_STATUS] [int] NOT NULL,
	[S_SETUP] [varchar](max) COLLATE SQL_Latin1_General_CP1_CI_AS NOT NULL,
	[U_ID] [int] NOT NULL,
 CONSTRAINT [PK_SIMULATION_TABLE] PRIMARY KEY CLUSTERED 
(
	[S_ID] ASC
)WITH (PAD_INDEX  = OFF, IGNORE_DUP_KEY = OFF) ON [PRIMARY]
) ON [PRIMARY]

GO
SET ANSI_PADDING OFF
GO
ALTER TABLE [dbo].[SIMULATION_TABLE]  WITH CHECK ADD  CONSTRAINT [FK_SIMULATION_TABLE_USER_TABLE] FOREIGN KEY([U_ID])
REFERENCES [dbo].[USER_TABLE] ([U_ID])
ON UPDATE CASCADE
ON DELETE CASCADE
GO
ALTER TABLE [dbo].[SIMULATION_TABLE] CHECK CONSTRAINT [FK_SIMULATION_TABLE_USER_TABLE]



USE [SimulationDevDB]
GO
/****** Object:  Table [dbo].[TRAINING_TABLE]    Script Date: 04/29/2011 13:02:46 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
SET ANSI_PADDING ON
GO
CREATE TABLE [dbo].[TRAINING_TABLE](
	[T_ID] [int] IDENTITY(1,1) NOT NULL,
	[T_NAME] [varchar](50) COLLATE SQL_Latin1_General_CP1_CI_AS NOT NULL,
	[T_DESC] [varchar](50) COLLATE SQL_Latin1_General_CP1_CI_AS NOT NULL,
	[T_SETUP] [varchar](max) COLLATE SQL_Latin1_General_CP1_CI_AS NOT NULL,
	[U_ID] [int] NOT NULL,
 CONSTRAINT [PK_TRAINING_TABLE] PRIMARY KEY CLUSTERED 
(
	[T_ID] ASC
)WITH (PAD_INDEX  = OFF, IGNORE_DUP_KEY = OFF) ON [PRIMARY]
) ON [PRIMARY]

GO
SET ANSI_PADDING OFF
GO
ALTER TABLE [dbo].[TRAINING_TABLE]  WITH CHECK ADD  CONSTRAINT [FK_TRAINING_TABLE_USER_TABLE] FOREIGN KEY([U_ID])
REFERENCES [dbo].[USER_TABLE] ([U_ID])
ON UPDATE CASCADE
ON DELETE CASCADE
GO
ALTER TABLE [dbo].[TRAINING_TABLE] CHECK CONSTRAINT [FK_TRAINING_TABLE_USER_TABLE]



USE [SimulationDevDB]
GO
/****** Object:  Table [dbo].[REPORT_TABLE]    Script Date: 04/29/2011 13:02:18 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
SET ANSI_PADDING ON
GO
CREATE TABLE [dbo].[REPORT_TABLE](
	[R_ID] [int] IDENTITY(1,1) NOT NULL,
	[S_ID] [int] NOT NULL,
	[R_STATUS] [varchar](50) COLLATE SQL_Latin1_General_CP1_CI_AS NOT NULL,
	[R_DATA] [varbinary](max) NULL,
	[R_TIMESTAMP] [datetime] NULL,
 CONSTRAINT [PK_REPORT_TABLE] PRIMARY KEY CLUSTERED 
(
	[R_ID] ASC
)WITH (PAD_INDEX  = OFF, IGNORE_DUP_KEY = OFF) ON [PRIMARY]
) ON [PRIMARY]

GO
SET ANSI_PADDING OFF
GO
ALTER TABLE [dbo].[REPORT_TABLE]  WITH CHECK ADD  CONSTRAINT [FK_REPORT_TABLE_SIMULATION_TABLE] FOREIGN KEY([S_ID])
REFERENCES [dbo].[SIMULATION_TABLE] ([S_ID])
ON UPDATE CASCADE
ON DELETE CASCADE
GO
ALTER TABLE [dbo].[REPORT_TABLE] CHECK CONSTRAINT [FK_REPORT_TABLE_SIMULATION_TABLE]




USE [SimulationDevDB]
GO
/****** Object:  Table [dbo].[PLAYER_TABLE]    Script Date: 04/29/2011 13:01:58 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
SET ANSI_PADDING ON
GO
CREATE TABLE [dbo].[PLAYER_TABLE](
	[P_ID] [int] IDENTITY(1,1) NOT NULL,
	[P_NAME] [varchar](50) COLLATE SQL_Latin1_General_CP1_CI_AS NOT NULL,
	[P_DESC] [varchar](50) COLLATE SQL_Latin1_General_CP1_CI_AS NOT NULL,
	[P_SETUP] [varchar](max) COLLATE SQL_Latin1_General_CP1_CI_AS NOT NULL,
	[U_ID] [int] NOT NULL,
 CONSTRAINT [PK_PLAYER_TABLE] PRIMARY KEY CLUSTERED 
(
	[P_ID] ASC
)WITH (PAD_INDEX  = OFF, IGNORE_DUP_KEY = OFF) ON [PRIMARY]
) ON [PRIMARY]

GO
SET ANSI_PADDING OFF
GO
ALTER TABLE [dbo].[PLAYER_TABLE]  WITH CHECK ADD  CONSTRAINT [FK_PLAYER_TABLE_USER_TABLE] FOREIGN KEY([U_ID])
REFERENCES [dbo].[USER_TABLE] ([U_ID])
ON UPDATE CASCADE
ON DELETE CASCADE
GO
ALTER TABLE [dbo].[PLAYER_TABLE] CHECK CONSTRAINT [FK_PLAYER_TABLE_USER_TABLE]


USE [SimulationDevDB]
GO
/****** Object:  Table [dbo].[INJURY_TABLE]    Script Date: 04/29/2011 13:01:36 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
SET ANSI_PADDING ON
GO
CREATE TABLE [dbo].[INJURY_TABLE](
	[I_ID] [int] IDENTITY(1,1) NOT NULL,
	[I_NAME] [varchar](50) COLLATE SQL_Latin1_General_CP1_CI_AS NOT NULL,
	[I_DESC] [varchar](50) COLLATE SQL_Latin1_General_CP1_CI_AS NOT NULL,
	[I_SETUP] [varchar](max) COLLATE SQL_Latin1_General_CP1_CI_AS NOT NULL,
	[U_ID] [int] NOT NULL,
 CONSTRAINT [PK_INJURY_TABLE] PRIMARY KEY CLUSTERED 
(
	[I_ID] ASC
)WITH (PAD_INDEX  = OFF, IGNORE_DUP_KEY = OFF) ON [PRIMARY]
) ON [PRIMARY]

GO
SET ANSI_PADDING OFF
GO
ALTER TABLE [dbo].[INJURY_TABLE]  WITH CHECK ADD  CONSTRAINT [FK_INJURY_TABLE_USER_TABLE] FOREIGN KEY([U_ID])
REFERENCES [dbo].[USER_TABLE] ([U_ID])
ON UPDATE CASCADE
ON DELETE CASCADE
GO
ALTER TABLE [dbo].[INJURY_TABLE] CHECK CONSTRAINT [FK_INJURY_TABLE_USER_TABLE]


/****** SQL STORED PROCEDURES ******/

GO
CREATE PROCEDURE [dbo].[DELETE_INJURY]
	-- Add the parameters for the stored procedure here
	@ID int
AS
BEGIN
	-- SET NOCOUNT ON added to prevent extra result sets from
	-- interfering with SELECT statements.
	SET NOCOUNT ON;

    -- Insert statements for procedure here
	DELETE INJURY_TABLE WHERE I_ID=@ID
END


GO
-- =============================================
-- Author:		<Author,,Name>
-- Create date: <Create Date,,>
-- Description:	<Description,,>
-- =============================================
CREATE PROCEDURE [dbo].[DELETE_PLAYER]
	-- Add the parameters for the stored procedure here
	@ID int
AS
BEGIN
	-- SET NOCOUNT ON added to prevent extra result sets from
	-- interfering with SELECT statements.
	SET NOCOUNT ON;

    -- Insert statements for procedure here
	DELETE PLAYER_TABLE WHERE P_ID=@ID
END




GO
-- =============================================
-- Author:		<Author,,Name>
-- Create date: <Create Date,,>
-- Description:	<Description,,>
-- =============================================
CREATE PROCEDURE [dbo].[DELETE_SIMULATION]
	-- Add the parameters for the stored procedure here
	@ID int
AS
BEGIN
	-- SET NOCOUNT ON added to prevent extra result sets from
	-- interfering with SELECT statements.
	SET NOCOUNT ON;

    -- Insert statements for procedure here
	DELETE SIMULATION_TABLE WHERE S_ID=@ID
END



GO
-- =============================================
-- Author:		<Author,,Name>
-- Create date: <Create Date,,>
-- Description:	<Description,,>
-- =============================================
CREATE PROCEDURE [dbo].[DELETE_TRAINING]
	-- Add the parameters for the stored procedure here
	@ID int
AS
BEGIN
	-- SET NOCOUNT ON added to prevent extra result sets from
	-- interfering with SELECT statements.
	SET NOCOUNT ON;

    -- Insert statements for procedure here
	DELETE TRAINING_TABLE WHERE T_ID=@ID
END


GO
-- =============================================
-- Author:		<Author,,Name>
-- Create date: <Create Date,,>
-- Description:	<Description,,>
-- =============================================
CREATE PROCEDURE [dbo].[FET_ALL_PLAYERS]
	-- Add the parameters for the stored procedure here
AS
BEGIN
	-- SET NOCOUNT ON added to prevent extra result sets from
	-- interfering with SELECT statements.
	SET NOCOUNT ON;

    
	SELECT * FROM PLAYER_TABLE
END




GO
-- =============================================
-- Author:		<Author,,Name>
-- Create date: <Create Date,,>
-- Description:	<Description,,>
-- =============================================
CREATE PROCEDURE [dbo].[FET_INJURIES]
	-- Add the parameters for the stored procedure here
	@ID int
AS
BEGIN
	-- SET NOCOUNT ON added to prevent extra result sets from
	-- interfering with SELECT statements.
	SET NOCOUNT ON;

    
	SELECT * FROM INJURY_TABLE WHERE U_ID=@ID
END


GO
-- =============================================
-- Author:		<Author,,Name>
-- Create date: <Create Date,,>
-- Description:	<Description,,>
-- =============================================
CREATE PROCEDURE [dbo].[FET_INJURY]
	-- Add the parameters for the stored procedure here
	@ID int
AS
BEGIN
	-- SET NOCOUNT ON added to prevent extra result sets from
	-- interfering with SELECT statements.
	SET NOCOUNT ON;

    
	SELECT * FROM INJURY_TABLE WHERE I_ID=@ID
END




GO
-- =============================================
-- Author:		<Author,,Name>
-- Create date: <Create Date,,>
-- Description:	<Description,,>
-- =============================================
CREATE PROCEDURE [dbo].[FET_PLAYER]
	-- Add the parameters for the stored procedure here
	@ID int
AS
BEGIN
	-- SET NOCOUNT ON added to prevent extra result sets from
	-- interfering with SELECT statements.
	SET NOCOUNT ON;

    
	SELECT * FROM PLAYER_TABLE WHERE P_ID=@ID
END




GO
-- =============================================
-- Author:		<Author,,Name>
-- Create date: <Create Date,,>
-- Description:	<Description,,>
-- =============================================
CREATE PROCEDURE [dbo].[FET_PLAYERS]
	-- Add the parameters for the stored procedure here
	@ID int
AS
BEGIN
	-- SET NOCOUNT ON added to prevent extra result sets from
	-- interfering with SELECT statements.
	SET NOCOUNT ON;

    
	SELECT * FROM PLAYER_TABLE WHERE U_ID=@ID
END


GO
-- =============================================
-- Author:		<Author,,Name>
-- Create date: <Create Date,,>
-- Description:	<Description,,>
-- =============================================
CREATE PROCEDURE [dbo].[FET_REPORTS]
	-- Add the parameters for the stored procedure here
	@ID int
AS
BEGIN
	-- SET NOCOUNT ON added to prevent extra result sets from
	-- interfering with SELECT statements.
	SET NOCOUNT ON;

    
	SELECT * FROM REPORT_TABLE, SIMULATION_TABLE WHERE SIMULATION_TABLE.S_ID=@ID ORDER BY R_TIMESTAMP DESC

END



GO
-- =============================================
-- Author:		<Author,,Name>
-- Create date: <Create Date,,>
-- Description:	<Description,,>
-- =============================================
CREATE PROCEDURE [dbo].[FET_REPORT]
	-- Add the parameters for the stored procedure here
	@ID int
AS
BEGIN
	-- SET NOCOUNT ON added to prevent extra result sets from
	-- interfering with SELECT statements.
	SET NOCOUNT ON;

    
	SELECT * FROM REPORT_TABLE WHERE R_ID=@ID
END




GO
-- =============================================
-- Author:		<Author,,Name>
-- Create date: <Create Date,,>
-- Description:	<Description,,>
-- =============================================
CREATE PROCEDURE [dbo].[FET_SIMULATION]
	-- Add the parameters for the stored procedure here
	@ID int
AS
BEGIN
	-- SET NOCOUNT ON added to prevent extra result sets from
	-- interfering with SELECT statements.
	SET NOCOUNT ON;

    
	SELECT * FROM SIMULATION_TABLE WHERE S_ID=@ID
END


GO
-- =============================================
-- Author:		<Author,,Name>
-- Create date: <Create Date,,>
-- Description:	<Description,,>
-- =============================================
CREATE PROCEDURE [dbo].[FET_SIMULATIONS]
	-- Add the parameters for the stored procedure here
	@ID int
AS
BEGIN
	-- SET NOCOUNT ON added to prevent extra result sets from
	-- interfering with SELECT statements.
	SET NOCOUNT ON;

    
	SELECT * FROM SIMULATION_TABLE WHERE U_ID=@ID
END



GO
-- =============================================
-- Author:		<Author,,Name>
-- Create date: <Create Date,,>
-- Description:	<Description,,>
-- =============================================
CREATE PROCEDURE [dbo].[FET_TRAINING]
	-- Add the parameters for the stored procedure here
	@ID int
AS
BEGIN
	-- SET NOCOUNT ON added to prevent extra result sets from
	-- interfering with SELECT statements.
	SET NOCOUNT ON;

    
	SELECT * FROM TRAINING_TABLE WHERE T_ID=@ID
END


GO
-- =============================================
-- Author:		<Author,,Name>
-- Create date: <Create Date,,>
-- Description:	<Description,,>
-- =============================================
CREATE PROCEDURE [dbo].[FET_TRAININGS]
	-- Add the parameters for the stored procedure here
	@ID int
AS
BEGIN
	-- SET NOCOUNT ON added to prevent extra result sets from
	-- interfering with SELECT statements.
	SET NOCOUNT ON;

    
	SELECT * FROM TRAINING_TABLE WHERE U_ID=@ID
END



GO
-- =============================================
-- Author:		<Author,,Name>
-- Create date: <Create Date,,>
-- Description:	<Description,,>
-- =============================================
CREATE PROCEDURE [dbo].[INS_NEW_DEFAULT_INJURY]
	@Name varchar(50),
	@Desc varchar(50),
	@Setup varchar(max),
	@Id int
AS
BEGIN
	-- SET NOCOUNT ON added to prevent extra result sets from
	-- interfering with SELECT statements.
	SET NOCOUNT ON;

   INSERT INTO INJURY_TABLE
	VALUES(@Name, @Desc, @Setup,@Id)

END



GO
-- =============================================
-- Author:		<Author,,Name>
-- Create date: <Create Date,,>
-- Description:	<Description,,>
-- =============================================
CREATE PROCEDURE [dbo].[INS_NEW_DEFAULT_PLAYER]
	@Name varchar(50),
	@Desc varchar(50),
	@Setup varchar(max),
	@Id int
AS
BEGIN
	-- SET NOCOUNT ON added to prevent extra result sets from
	-- interfering with SELECT statements.
	SET NOCOUNT ON;

   INSERT INTO PLAYER_TABLE
	VALUES(@Name, @Desc, @Setup,@Id)

END




GO
-- =============================================
-- Author:		<Author,,Name>
-- Create date: <Create Date,,>
-- Description:	<Description,,>
-- =============================================
CREATE PROCEDURE [dbo].[INS_NEW_REPORT_ENTRY]
	@sId int


AS
BEGIN
	-- SET NOCOUNT ON added to prevent extra result sets from
	-- interfering with SELECT statements.
	SET NOCOUNT ON;

   INSERT INTO REPORT_TABLE(S_ID,R_STATUS)
	VALUES(@sId, 'RUNNING')

	SELECT SCOPE_IDENTITY() AS [SCOPE_IDENTITY]


END



GO
-- =============================================
-- Author:		<Author,,Name>
-- Create date: <Create Date,,>
-- Description:	<Description,,>
-- =============================================
CREATE PROCEDURE [dbo].[INS_NEW_DEFAULT_SIMULATION]
	@Name varchar(50),
	@Desc varchar(50),
	@Status int,
	@Setup varchar(max),
	@Id int
AS
BEGIN
	-- SET NOCOUNT ON added to prevent extra result sets from
	-- interfering with SELECT statements.
	SET NOCOUNT ON;

   INSERT INTO SIMULATION_TABLE
	VALUES(@Name, @Desc, @Status,@Setup,@Id)

END



GO
-- =============================================
-- Author:		<Author,,Name>
-- Create date: <Create Date,,>
-- Description:	<Description,,>
-- =============================================
CREATE PROCEDURE [dbo].[INS_NEW_DEFAULT_TRAINING]
	@Name varchar(50),
	@Desc varchar(50),
	@Setup varchar(max),
	@Id int
AS
BEGIN
	-- SET NOCOUNT ON added to prevent extra result sets from
	-- interfering with SELECT statements.
	SET NOCOUNT ON;

    -- Insert statements for procedure here
	INSERT INTO TRAINING_TABLE
	VALUES(@Name, @Desc,@Setup,@Id)
END




GO
-- =============================================
-- Author:		<Author,,Name>
-- Create date: <Create Date,,>
-- Description:	<Description,,>
-- =============================================
CREATE PROCEDURE [dbo].[UPD_INJURY]
	-- Add the parameters for the stored procedure here
	@Id int,
	@Name varchar(50),
	@Desc varchar(50),
	@Setup varchar(max)
AS
BEGIN
	-- SET NOCOUNT ON added to prevent extra result sets from
	-- interfering with SELECT statements.
	SET NOCOUNT ON;

   UPDATE INJURY_TABLE
	SET
		I_NAME = @Name,
		I_DESC = @Desc,
		I_SETUP= @Setup
	WHERE
		I_ID=@Id
END



GO
-- =============================================
-- Author:		<Author,,Name>
-- Create date: <Create Date,,>
-- Description:	<Description,,>
-- =============================================
CREATE PROCEDURE [dbo].[UPD_PLAYER]
	-- Add the parameters for the stored procedure here
	@Id int,
	@Name varchar(50),
	@Desc varchar(50),
	@Setup varchar(max)
AS
BEGIN
	-- SET NOCOUNT ON added to prevent extra result sets from
	-- interfering with SELECT statements.
	SET NOCOUNT ON;

   UPDATE PLAYER_TABLE
	SET
		P_NAME = @Name,
		P_DESC = @Desc,
		P_SETUP= @Setup
	WHERE
		P_ID=@Id
END




GO
-- =============================================
-- Author:		<Author,,Name>
-- Create date: <Create Date,,>
-- Description:	<Description,,>
-- =============================================
CREATE PROCEDURE [dbo].[UPD_REPORT_ENTRY_FAILED]
	@rId int

AS
BEGIN
	-- SET NOCOUNT ON added to prevent extra result sets from
	-- interfering with SELECT statements.
	SET NOCOUNT ON;

    UPDATE REPORT_TABLE
	SET
		R_STATUS='FAILED',
		R_TIMESTAMP = CURRENT_TIMESTAMP
	WHERE
		R_ID=@rId


END


GO
-- =============================================
-- Author:		<Author,,Name>
-- Create date: <Create Date,,>
-- Description:	<Description,,>
-- =============================================
CREATE PROCEDURE [dbo].[UPD_REPORT_ENTRY_SUCCESS]

	@rId int,
	@sData varbinary(MAX)

AS
BEGIN
	-- SET NOCOUNT ON added to prevent extra result sets from
	-- interfering with SELECT statements.
	SET NOCOUNT ON;

    UPDATE REPORT_TABLE
	SET
		R_STATUS='SUCCESS',
		R_DATA = @sData,
		R_TIMESTAMP = CURRENT_TIMESTAMP
	WHERE
		R_ID=@rId


END




GO
-- =============================================
-- Author:		<Author,,Name>
-- Create date: <Create Date,,>
-- Description:	<Description,,>
-- =============================================
CREATE PROCEDURE [dbo].[UPD_SIMULATION]
	-- Add the parameters for the stored procedure here
	@Id int,
	@Name varchar(50),
	@Desc varchar(50),
	@Setup varchar(max)
AS
BEGIN
	-- SET NOCOUNT ON added to prevent extra result sets from
	-- interfering with SELECT statements.
	SET NOCOUNT ON;

   UPDATE SIMULATION_TABLE
	SET
		S_NAME = @Name,
		S_DESC = @Desc,
		S_SETUP= @Setup
	WHERE
		S_ID=@Id
END



GO
-- =============================================
-- Author:		<Author,,Name>
-- Create date: <Create Date,,>
-- Description:	<Description,,>
-- =============================================
CREATE PROCEDURE [dbo].[UPD_TRAINING]
	-- Add the parameters for the stored procedure here
	@Id int,
	@Name varchar(50),
	@Desc varchar(50),
	@Setup varchar(max)
AS
BEGIN
	-- SET NOCOUNT ON added to prevent extra result sets from
	-- interfering with SELECT statements.
	SET NOCOUNT ON;

   UPDATE TRAINING_TABLE
	SET
		T_NAME = @Name,
		T_DESC = @Desc,
		T_SETUP= @Setup
	WHERE
		T_ID=@Id
END



GO
-- =============================================
-- Author:		<Author,,Name>
-- Create date: <Create Date,,>
-- Description:	<Description,,>
-- =============================================
CREATE PROCEDURE [dbo].[FET_USER]
	@U_NAME varchar(50),
	@U_PASSWORD varchar(50)
AS
BEGIN
	-- SET NOCOUNT ON added to prevent extra result sets from
	-- interfering with SELECT statements.
	SET NOCOUNT ON;

    -- Insert statements for procedure here
	SELECT * FROM USER_TABLE WHERE U_NAME like @U_NAME AND U_PASSWORD like @U_PASSWORD
END


GO
-- =============================================
-- Author:		<Author,,Name>
-- Create date: <Create Date,,>
-- Description:	<Description,,>
-- =============================================
CREATE PROCEDURE [dbo].[INS_NEW_USER]
	-- Add the parameters for the stored procedure here
	@U_NAME varchar(50),
    @U_PASSWORD varchar(50),
    @U_EMAIL varchar(50),
    @U_SETUP varchar(MAX)

AS
BEGIN
	-- SET NOCOUNT ON added to prevent extra result sets from
	-- interfering with SELECT statements.
	SET NOCOUNT ON;

    -- Insert statements for procedure here
	INSERT INTO [SimulationDevDB].[dbo].[USER_TABLE]
           (U_NAME
           ,U_PASSWORD
           ,U_EMAIL
           ,U_SETUP)
     VALUES
           (@U_NAME
           ,@U_PASSWORD
           ,@U_EMAIL
           ,@U_SETUP)

	SELECT SCOPE_IDENTITY() AS [SCOPE_IDENTITY]

END




GO
-- =============================================
-- Author:		<Author,,Name>
-- Create date: <Create Date,,>
-- Description:	<Description,,>
-- =============================================
CREATE PROCEDURE [dbo].[INS_NEW_USER]
	-- Add the parameters for the stored procedure here
	@U_NAME varchar(50),
    @U_PASSWORD varchar(50),
    @U_EMAIL varchar(50),
    @U_SETUP varchar(MAX)

AS
BEGIN
	-- SET NOCOUNT ON added to prevent extra result sets from
	-- interfering with SELECT statements.
	SET NOCOUNT ON;

    -- Insert statements for procedure here
	INSERT INTO [SimulationDevDB].[dbo].[USER_TABLE]
           (U_NAME
           ,U_PASSWORD
           ,U_EMAIL
           ,U_SETUP)
     VALUES
           (@U_NAME
           ,@U_PASSWORD
           ,@U_EMAIL
           ,@U_SETUP)

	SELECT SCOPE_IDENTITY() AS [SCOPE_IDENTITY]

END

